
package student;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;


public class student {
	
	

		
	
public static void main(String[] args) throws ClassNotFoundException,SQLException{
	  Class.forName("com.mysql.jdbc.Driver");
	  String url="jdbc:mysql://localhost:3306/jsp";
	  String username="root";
	  String password="root";
	  Connection conn=DriverManager.getConnection(url,username,password);
      String insertSqlStatic="insert into tb_student(age,sex,name,id) values('17','5','lisi','4')";
    
	Statement bs=conn.prepareStatement(insertSqlStatic);
      bs.executeUpdate(insertSqlStatic);
      String selectSql="select from tb_student";
      PreparedStatement ps=conn.prepareStatement(selectSql);
      ResultSet rs=ps.executeQuery(selectSql);
      while(rs.next()) {
    	  System.out.println("id:"+rs.getString(2)+",student name is"+rs.getString(1));
    	  
    	  
    	  
      }    

			
	
	 
	
}
      
      
}	 